import 'package:cher_flare/routes/app_pages.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../utils/app_color.dart';
import '../../../utils/ly_medal_manager.dart';

class LYCongratulationsPage extends StatefulWidget {
  final LYMedalType type;

  const LYCongratulationsPage({super.key, required this.type});

  @override
  State<LYCongratulationsPage> createState() => _LYCongratulationsPageState();
}

class _LYCongratulationsPageState extends State<LYCongratulationsPage> {
  void _sureButtonDidClick() {
    Get.offNamed(AppPages.medalPage);
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        _makeContentWidget(),
      ],
    );
  }

  Widget _makeContentWidget() {
    return Stack(
      fit: StackFit.loose,
      alignment: Alignment.center,
      children: [
        SizedBox(
          child: Container(
            margin: const EdgeInsets.only(left: 30, right: 30, top: 10),
            decoration: BoxDecoration(
                color: AppColors.whiteColor,
                borderRadius: BorderRadius.circular(16),
                gradient: const LinearGradient(
                    colors: [Color(0xfff4ffe9), Color(0xfff6f7f8)])),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                    alignment: Alignment.center,
                    padding: const EdgeInsets.only(top: 45),
                    child: Image.asset(
                      'assets/images/${_imageName()}',
                      width: 80,
                      height: 80,
                    )),
                Container(
                  alignment: Alignment.center,
                  padding: const EdgeInsets.only(top: 17, left: 28, right: 28),
                  child: const Text(
                    'Congratulations on your successful registration and winning the badge. You can go to the medal page to view and upgrade him.',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.bold,
                        color: AppColors.color404040),
                  ),
                ),
                Container(
                  height: 100,
                  width: double.infinity,
                  padding: const EdgeInsets.only(bottom: 16),
                  alignment: Alignment.bottomCenter,
                  decoration: const BoxDecoration(
                      image: DecorationImage(
                          image: AssetImage('assets/images/buy_bg_img.png'),
                          fit: BoxFit.fill)),
                  child: InkWell(
                    onTap: () => _sureButtonDidClick(),
                    child: Container(
                      width: 117,
                      height: 38,
                      alignment: Alignment.center,
                      decoration: const BoxDecoration(
                          image: DecorationImage(
                              image: AssetImage(
                                  'assets/images/buy_btn_bg_icon.png'),
                              fit: BoxFit.cover)),
                      child: const Text(
                        'Check it',
                        style: TextStyle(
                            fontWeight: FontWeight.bold,
                            color: AppColors.color202020,
                            fontSize: 14),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
        Positioned(
            top: 0,
            child: Image.asset(
              'assets/images/congratulations_icon.png',
              width: 163,
              height: 36,
            )),
      ],
    );
  }

  String _imageName() {
    if (widget.type == LYMedalType.germination) {
      return "onset_oath _badge_left.png";
    } else if (widget.type == LYMedalType.seedlingStage) {
      return "steadfast_streak_crest_l.png";
    } else if (widget.type == LYMedalType.saplingStage) {
      return "persistent_pledge_medallion_l.png";
    }
    return "triumphant_commitment_emblem_l.png";
  }
}
